package com.designpattern.behavior.intermediary;

/**
 * @author Administration
 * @date 2021/10/26 - 16:29 - 星期二
 * @project 行为型模式中的中介者模式  具体中介者角色
 * @package com.designpattern.behavior.intermediary
 * @by 晨
 */
public class MediatorStructure extends Mediator{

    //首先中介结构必须知道所有房主和租房者的信息
    private HouseOwner houseOwner;
    private Tenant tenant;

    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    @Override
    public void constact(String message, Preson preson) {
        if (preson == houseOwner) {  // 如果是房主  则租房者获得信息
            tenant.getMessage(message);
        } else {
            houseOwner.getMessage(message); // 是租房者 则获取房主的信息
        }

    }
}
